package com.ssy.lingxi.purchase.api.enums.purchase;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 采购能力-采购询价单  内部操作记录状态枚举
 *
 * @author lxc
 * @date 2022/2/25
 */
public enum PurchaseInquiryInternalOperationRecordEnum {

    ADD(1, "新增需求单"),
    UPDATE(2, "修改需求单"),
    SUBMIT_EXAMINE(3, "提交审核采购需求单"),
    EXAMINE1(4, "审核采购需求单(一级)"),
    SUBMIT_EXAMINE1(5, "提交审核采购需求单(一级)"),
    EXAMINE2(6, "审核采购需求单(二级)"),
    SUBMIT_EXAMINE2(7, "提交审核采购需求单(二级)"),
    SUBMIT(8, "提交采购需求单"),
    TO_BE_COMPARED(9, "待比价"),
    REVIEW_AWARD_RESULTS1(10, "待审核授标结果(一级)"),
    REVIEW_AWARD_RESULTS2(11, "待审核授标结果(二级)"),
    CONFIRM_THE_RESULT_OF_THE_AUDIT_AWARD(12, "待确认授标结果"),
        ;
    private Integer state;
    private String name;

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    /**
     * 针对数据库储存Integer类型字段
     * @return
     */
    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.state);
    }

    /**
     * 针对数据库储存String类型字段
     * @return
     */
    public String getCHName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    PurchaseInquiryInternalOperationRecordEnum(Integer state, String name) {
        this.state = state;
        this.name = name;
    }

    public static String getName(String name){
        PurchaseInquiryInternalOperationRecordEnum workEnum = Arrays.stream(PurchaseInquiryInternalOperationRecordEnum.values()).filter(v -> v.getCHName().equals(name)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(PurchaseInquiryInternalOperationRecordEnum.class, workEnum.getState());
    }
}
